import * as kcors from 'kcors';
const session = require('koa-session2');

import Server from './lib';
import { restApi, queryToJson, authorityHandler } from './middlewares';


const server = new Server({
    port: 8000,
    routerPath: `${__dirname}/router`,
    servicePath: `${__dirname}/service`,
    controllerPath: `${__dirname}/controller`,
    routerPrefix: '/api',
    middlewares: [kcors({ credentials: true }), restApi('/api'), session({
        key: 'SESSIONID',
        maxAge: 1000 * 60 * 10,
        httpOnly: true,
        overwrite: false
    }), queryToJson('/api'), authorityHandler()]
});
server.on('error', err => {
    console.log(err);
});
export default server;